package com.mew.chess.core.game.dyj.game.common;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author dylin
 * @create 2021/4/25
 */
public enum DyjBetType {
    Big(0, 10 ),//"大"
    Small(1, 10 ),//"小"
    Pair(2, 12),//"对子"
    Straight(3, 70 ),//"顺子"
    Leopard(4,300 ),//"豹子"
    ;

    private final int code;
    private final int rate;

    /**
     * @param code 代码
     * @param rate 倍数
     */
    private DyjBetType(final int code, int rate) {
        this.code = code;
        this.rate = rate;
    }

    private final static Map<Integer, DyjBetType> stateMap
            = Arrays.stream(DyjBetType.values()).collect(Collectors.toMap(DyjBetType::code, code -> code));

    public int code() {
        return this.code;
    }

    public int rate() {
        return this.rate;
    }


    public static DyjBetType parse(int code) {
        return stateMap.get(code);
    }
}
